package com.my.controller;


import com.my.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/address")
@CrossOrigin("*")
@RestController
public class AddressController {

    private AddressService addressService;

    @Autowired
    public void setAddressService(AddressService addressService) {
        this.addressService = addressService;
    }

    @RequestMapping("/show")
    public String showAddress(HttpServletRequest req) {
        return this.addressService.showAddress(req);
    }

    @RequestMapping("/add")
    public String addAddress(String province, String city, String district, String address, String code, String phone, String name, HttpServletRequest req) {
        return this.addressService.addAddress(province, city, district, address, code, phone, name, req);
    }

    @RequestMapping("/update")
    public String updateAddress(Integer id, String province, String city, String district, String address, String code, String phone, String name) {
        return this.addressService.updateAddress(id, province, city, district, address, code, phone, name);
    }

    @RequestMapping("/delete")
    public String deleteAddress(Integer addressId, HttpServletRequest req) {
        return this.addressService.deleteAddress(addressId, req);
    }

    @RequestMapping("/selById")
    public String selById(Integer id) {
        return this.addressService.selById(id);
    }

    @RequestMapping("/updateStatus")
    public String updateStatus(Integer ori_id, Integer id) {
        return this.addressService.updateStatus(ori_id, id);
    }
}
